<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="app">
        <form action="">
            <div>
                用户名：
                <input type="text" v-on:keyup.delete="clear" v-model="uname" />
                <!-- 按键修饰符 .delete 删除键 删除内容 -->
            </div>
            <div>
                密码:
                <input type="text" v-on:keyup.enter="handle" v-on:keyup.delete="clearpwd" v-model="pwd" />
                <!-- 按键修饰符 .enter 回车键 v-on:keyup.enter='对应事件' -->
            </div>
            <div><input type="button" v-on:click="handle" value="提交" /></div>
        </form>
    </div>
    <script src="./vue.js"></script>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                uname: "",
                pwd: "",
            },
            methods: {
                handle: function() {
                    console.log(this.uname, this.pwd);
                },
                clear: function() {
                    this.uname = "";
                    // 按delete 清空uname 用户名的信息
                },
                clearpwd: function() {
                    this.pwd = "";
                },
            },
        });
    </script>
</body>

</html>